import java.util.Random;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Random random = new Random();
        int num = random.nextInt(100);

        Scanner scan = new Scanner(System.in);
        while(true){
            System.out.println("请输入一个你要猜的数字:");
            int i = scan. nextInt();

            if(i > num){
                System.out.println("猜大了！");
            }else if(i == num){
                System.out.println("猜对了！");
                break;
            }else {         //注意此处else无语句（）
                System.out.println("猜小了！");
            }
        }

    }

    //基础知识
    public static void main1(String[] args) {
        //生成随机数
        Random random = new Random();
        int num = random.nextInt(100);      //生成随机数范围[0,100)不包括100
        System.out.println(num);

        //从键盘输入一个整数
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        System.out.println(i);


    }
}
